﻿using System;

namespace NimbleTextKeygen
{
    class Program
    {
        static void Main(string[] args)
        {
            // ReSharper disable once InconsistentNaming
            var productID = AssemblyAttributes.ProductID;
            var productName = AssemblyAttributes.ProductName;
            var uniqueCode = IOUtils.GenerateUniqueCode();
            var machineName = AssemblyAttributes.MachineName();
            var activationCode = IOUtils.CreateActivationCode(productName, uniqueCode, machineName, productID);
            var isOk = IOUtils.CheckActivationCode(activationCode, productName, uniqueCode, machineName, productID);

            var (settings, _) = IOUtils.LoadSettingsFromConfig();
            settings.ActivationCode = activationCode;
            settings.UniqueCode = uniqueCode;

            if (isOk)
            {
                IOUtils.SaveSettings(settings);
                Console.WriteLine("License has been written");
            }


            Console.WriteLine($"ActivationCode={activationCode}");
            Console.WriteLine($"UniqueCode={uniqueCode}");

            Console.ReadKey();
        }
    }
}
